import React, { Component, createRef, forwardRef } from 'react'


//高阶组件 forwordRef
const Profile = forwardRef(function(props, ref) {
  return <p ref={ref}>函数组件的ref</p>
})

export default class App extends Component {
  constructor() {
    super()

    this.profileRef = createRef()
  }
  
  render() {
    return (
      <div>
        <Profile ref={this.profileRef} />

        <button onClick={e => this.btnClick()}>按钮</button>
      </div>
    )
  }

  btnClick() {
    console.log(this.profileRef.current);
  }
}
